home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: 4 April 1997
- //
- // Procedure Name:
- // performPolySubdivide
- //
- // Description:
- // subdivide the selected polygon facets or edges
- //
- // Input Arguments:
- // $option : Whether to set the options to default values.
- // Return Value:
- // command string iff $option==2
- //
-
- proc setOptionVars (string $comp, int $forceFactorySettings)
- {
- if ($forceFactorySettings || !`optionVar -exists ("polySubdSubd" + $comp)`)
- optionVar -intValue ("polySubdSubd" + $comp) 1;
- if ($comp =="f") {
- if ($forceFactorySettings || !`optionVar -exists ("polySubdFacetMode" + $comp)`)
- optionVar -intValue ("polySubdFacetMode" + $comp) 1;
- } else {
- if ($forceFactorySettings || !`optionVar -exists ("polySubdLen" + $comp)`)
- optionVar -floatValue ("polySubdLen" + $comp) 0;
- if ($forceFactorySettings || !`optionVar -exists ("polySubdWS" + $comp)`)
- optionVar -intValue ("polySubdWS" + $comp) 0;
- }
- }
-
- global proc performPolySubdivideSetup (string $comp, string $parent, int $forceFactorySettings)
- {
- setOptionVars($comp, $forceFactorySettings);
- setParent $parent;
-
- int $ival = `optionVar -query ("polySubdSubd" + $comp)`;
- intSliderGrp -edit -value $ival polySubdSubd;
- if ($comp =="f") {
- int $ival = `optionVar -query ("polySubdFacetMode" + $comp)`;
- optionMenuGrp -edit -sl $ival polySubdFacetMode;
- } else {
- float $val = `optionVar -query ("polySubdLen" + $comp)`;
- floatSliderGrp -edit -value $val polySubdLen;
- int $ival = `optionVar -query ("polySubdWS" + $comp)`;
- checkBoxGrp -edit -value1 $ival polySubdWS;
- }
- }
-
- global proc performPolySubdivideCallback (string $comp, string $parent, int $doIt)
- {
- setParent $parent;
-
- optionVar -intValue ("polySubdSubd" + $comp)
- `intSliderGrp -query -value polySubdSubd`;
- if ($comp =="f")
- optionVar -intValue ("polySubdFacetMode" + $comp)
- `optionMenuGrp -query -sl polySubdFacetMode`;
- else {
- optionVar -floatValue ("polySubdLen" + $comp)
- `floatSliderGrp -query -value polySubdLen`;
- optionVar -intValue ("polySubdWS" + $comp)
- `checkBoxGrp -query -value1 polySubdWS`;
- }
- if ($doIt) {
- performPolySubdivide $comp 0;
- string $tmpCmd = "performPolySubdivide \"" + $comp + "\" 0";
- string $tmpLabel = "PolySubdivideEdge";
- if ($comp =="f") $tmpLabel = "PolySubdivideFacet";
- addToRecentCommandQueue $tmpCmd $tmpLabel;
- }
- }
-
- proc polySubdivideOptions (string $comp)
- {
- string $commandName = "performPolySubdivide";
- string $callback = ($commandName + "Callback " + $comp);
- string $setup = ($commandName + "Setup " + $comp);
-
- string $layout = getOptionBox();
- setParent $layout;
- setUITemplate -pushTemplate DefaultTemplate;
- waitCursor -state 1;
-
- string $parent = `columnLayout -adjustableColumn 1`;
-
- intSliderGrp -label "Subdivision Levels" -min 1 -max 4 polySubdSubd;
-
- if ($comp == "f")
- {
- optionMenuGrp -l "Mode" polySubdFacetMode;
- menuItem -l "quads" SubdFacetQuadsMenuItem;
- menuItem -l "triangles" SubdFacetTrgsMenuItem;
- setParent -m ..;
- optionMenuGrp -e -sl 1 polySubdFacetMode;
- }
- else {
- floatSliderGrp -label "Minimum Length" -min 0 -max 10 -fmn 0 -fmx 1000 polySubdLen;
- checkBoxGrp -label1 "Worldspace" polySubdWS;
- }
- waitCursor -state 0;
- setUITemplate -popTemplate;
-
- string $applyBtn = getOptionBoxApplyBtn();
- button -edit -label "Subdivide"
- -command ($callback + " " + $parent + " " + 1)
- $applyBtn;
- string $saveBtn = getOptionBoxSaveBtn();
- button -edit
- -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox")
- $saveBtn;
- string $resetBtn = getOptionBoxResetBtn();
- button -edit
- -command ($setup + " " + $parent + " " + 1)
- $resetBtn;
-
- string $lbl="Edge"; string $obj="Edge";
- if ($comp == "f") { $lbl="Face"; $obj="Facet"; }
-
- setOptionBoxTitle("Polygon Subdivide " + $lbl + " Options");
-
- // Customize the 'Help' menu item text.
- //
- setOptionBoxHelpTag( "EditPolygonsSubdivide" );
-
- eval (($setup + " " + $parent + " " + 0));
- scriptJob -protected
- -parent $parent
- -event "SelectTypeChanged" "evalDeferred \"performPolySubdivide \\\"\\\" 1\"";
-
- showOptionBox();
- }
-
- global proc string performPolySubdivide (string $comp, int $option)
- {
- string $cmd="";
- string $obj="";
- if ($comp == "") {
- // If no comp is specified, use the selection list to decide on E/F
- if (size(`filterExpand -sm 34`) != 0) { $comp="f"; $obj="Facet"; }
- else if (size(`filterExpand -sm 32`) != 0) { $comp="e"; $obj="Edge"; }
- else {
- // If nothing is selected, check which is about to be selected!!
- if (`selectMode -q -object`) { // Object Selection Mode
- // Check for RMB component selection
- if (`selectType -q -ocm -facet`) { $comp="f"; $obj="Facet"; }
- else if (`selectType -q -ocm -edge`) { $comp="e"; $obj="Edge"; }
- } else { // Component Selection Mode
- if (`selectType -q -facet`) { $comp="f"; $obj="Facet"; }
- else if (`selectType -q -edge`) { $comp="e"; $obj="Edge"; }
- }
- if ($comp == "") { // If still unresolvable, give up!!
- if ($option == 1) { $comp="f"; $obj="Facet"; }
- else if ($option < 2) {
- warning "Polygons edges or faces must be selected to subdivide them.";
- return "";
- }
- }
- }
- } else {
- if ($comp == "f") $obj="Facet";
- else if ($comp == "e") $obj="Edge";
- else {
- if ($option < 2) {
- warning "Only Polygon edges and faces can be subdivided.";
- return "";
- }
- }
- }
- string $sel[];
- string $res[];
- switch ($option) {
- case 0:
- setOptionVars($comp, false);
- if ($comp == "f") {
- int $ival = `optionVar -query polySubdSubdf`;
- int $iv2 = `optionVar -query polySubdFacetModef` -1;
- $cmd=("polySubdivideFacet -dv " + $ival + " -m " + $iv2);
- } else {
- int $ival = `optionVar -query polySubdSubde`;
- float $val =`optionVar -query polySubdLene`;
- int $ws = `optionVar -query polySubdWSe`;
- $cmd=("polySubdivideEdge -ws " + $ws + " -s " + $val + " -dv " + $ival);
- }
- polyPerformAction $cmd $comp 0;
- break;
- case 1: polySubdivideOptions $comp; break;
- case 2:
- /*
- setOptionVars($comp, false);
- // note that by 'freezing' the parameters, we now have to stick
- // the shelf item to either 'subdivide edges' or 'subdivide facets'
- // hence the command losses a bit of functionality: instead of
- // smartly applying to either edges or facets, it will apply
- // to only one of those categories.
- if ($comp == "e") {
- int $ival = `optionVar -query polySubdSubde`;
- float $val =`optionVar -query polySubdLene`;
- int $ws = `optionVar -query polySubdWSe`;
- $cmd=("polySubdivideEdge -ws " + $ws + " -s " + $val + " -dv " + $ival);
- } else if ($comp == "f") {
- int $ival = `optionVar -query polySubdSubdf`;
- int $iv2 = `optionVar -query polySubdFacetModef` -1;
- $cmd=("polySubdivideFacet -dv " + $ival + " -m " + $iv2);
- } else $cmd="performPolySubdivide \"\" 0";
- if ($comp != "")
- $cmd=("polyPerformAction \""+ $cmd + "\" " + $comp + " 0");
- */
- $cmd="performPolySubdivide \"\" 0";
- }
- return $cmd;
- }
-